home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
program
/
recio214.zip
/
USAGE.TXT
< prev
Wrap
Text File
|
1996-06-14
|
34KB
|
945 lines
Title: STANDARD USAGE OF C LANGUAGE RECIO LIBRARY
Copyright: (C) 1994-1996, William Pierpoint
Version: 2.14
Date: June 14, 1996
1.0 INTRODUCTION
The implementation descibed by this standard usage is a superset of the
recio specification. Enhancements are noted in the text.
1.1 Mnemonics
The recio functions have been given a consistent mnemonic naming
convention. All recio functions are in lower case and start with
the letter r. Function names are analogous to <stdio.h> functions.
Mnemonics are as follows:
Single letter (field functions) Multi-letter
---------------------------------------- -----------------
b - base (prefix) beg - beginning
c - column (prefix), character (suffix) ch - character
d - double (suffix) col - column
f - float (suffix) cxt - context
i - integer (suffix) eof - end of file
l - long (suffix) err - error
n - number fld - field buffer
r - record pointer (first letter) fmt - format
s - string pointer (suffix) fn - function
t - time_t time (suffix) no - number
u - unsigned (suffix) num - number
rec - record buffer
siz - size of buffer
str - string
tm - struct tm time
txt - text
1.2 Order
The order in which the prefix mnemonics appear indicates the order in which
the arguments appear in the function. The suffix mnemonics of the input
functions tell you what the function returns. The suffix mnemonics of the
output functions indicate the last argument and tell you what the function
outputs. All output functions return an integer with a zero value if the
function executed successfully.
For example, the input function rbgetui():
arguments: r - record pointer
b - base (radix) of input
returns: ui - unsigned integer
The output function rbputui():
arguments: r - record pointer
b - base (radix) of input
ui - unsigned integer is output
Note: c is used in the prefix of a function's name only once even if there are
two column arguments. If the function inputs or outputs a character,
there is only one column argument; otherwise there are two.
2.0 ERRORS AND WARNINGS
The functions declared in the header <recio.h> make use of the errno macro
defined in section 4.1.3 of ANSI X3.159-1989. This mechanism was chosen
because (1) the <stdlib.h> conversion functions (strtod(), strtol(), etc.)
make use of this error reporting mechanism and (2) the <recio.h> functions
make use of the <stdlib.h> conversion functions.
In this implementation, errno can return the following macro constants:
0 - No error.
EACCES - permission denied.
EDOM - argument out of domain.
EINVAL - invalid argument.
EMFILE - too many open files.
ENOENT - no such file or directory.
ENOMEM - out of memory.
ERANGE - out of range.
where
* EACCESS means that you don't have permission to access this file. All
MSDOS files have read permission.
* EDOM says that the argument is ouside of the defined domain. For
example, if the days of the month are defined as 1 to 31 and you
convert a string "1/32/1995" using sftotm(), an EDOM error will occur.
* EINVAL indicates an invalid argument to a function, usually a NULL record
pointer. This is most often caused by a programming error.
* EMFILE means the program tried to open more files than the maximum allotted
by ROPEN_MAX or FOPEN_MAX. If your program is interactive, the user can
close one or more open record streams. Or you might decide that ROPEN_MAX
or FOPEN_MAX needs to be a larger value.
* ENOENT says that ropen() could not find the requested file to open.
Perhaps the name of the file was misspelled, or your program looked in
wrong directory. If your program was trying to read a configuration file,
it could use internal default values when the configuration file does
not exist.
* ENOMEM indicates that the program ran out of heap space. You may be able
to correct this if you are able to deallocate memory you no longer need.
For example, you could reduce the size of buffers when the size only
affects speed. Such buffers need to be flushed first. Buffers used by
the recio library do not fit this criteria.
* ERANGE tells you that the data is outside the capabilities of the data
type to represent it. The data value is either too large or too small.
Either the data is incorrect or you need a more robust data type to hold
the data.
Beginning with version 1.1, recio functions set errno when the record
pointer is invalid and set an internal error number when the record pointer
is valid. The recio error number is accessed through the rerror function.
The rerror function can return the following macro constants:
0 - No error.
R_EDOM - out of domain.
R_EINVAL - invalid argument (not the record pointer).
R_EINVDAT - invalid data.
R_EINVMOD - invalid mode.
R_EMISDAT - missing data.
R_ENOMEM - out of memory.
R_ENOPUT - unable to write data to output.
R_ERANGE - out of range.
R_EFAULT - application defined error.
where
* R_EDOM indicates an argument to a function is outside the defined
domain. For example, if base is defined to have a valid range of
2 - 32 and you pass a 1, an R_EDOM error occurs.
If the following conditions are not met, an R_EDOM error will result:
Input of integral numbers: 2 <= base <= 32 or base==0
Output of integral numbers: 2 <= base <= 32
Input of time: 1 <= month <= 12
1 <= day <= 31
0 <= hour <= 23
0 <= minute <= 59
0 <= second <= 61 (includes 2 leap seconds)
* R_EINVDAT says the data is invalid. Invalid data is caused by an
unrecognized character in the field. For example, if you read an
integral number that contained a letter, a R_EINVDAT error would
occur.
* R_EINVMOD indicates that you opened a file in read mode, then used an
output function or opened a file in write or append mode, then used an
input function.
* R_EMISDAT says the data is missing. Missing data means the field is empty.
If you expect a number, you could substitute either zero or some unique
number to indicate an empty field.
* R_ENOMEM indicates that the program ran out of heap space. You may be able
to correct this if you are able to deallocate memory you no longer need.
For example, you could reduce the size of buffers when the size only
affects speed. Such buffers need to be flushed first. Buffers used by
the recio library do not fit this criteria.
* R_ENOPUT says the program was unable to write the data to the output.
One possible cause is that the disk is full.
* R_ERANGE tells you that the data is outside the capabilities of the
data type to represent it. For instance, suppose you used rgeti()
to get an integer and the data value is 32768. If a 16-bit integer
has an upper limit of 32767, the value is too large. If the data is
wrong, you can have the error function correct it. If the data is
right, you need to correct the data type within the program.
If the following types of data are not within the following ranges,
a R_ERANGE error will occur:
integer: INT_MIN <= x <= INT_MAX
long: LONG_MIN <= x <= LONG_MAX
unsigned integer: 0 <= x <= UINT_MAX
unsigned long: 0 <= x <= ULONG_MAX
float: -FLT_MAX <= x <= -FLT_MIN or FLT_MIN <= x <= FLT_MAX or x==0.0
double: -DBL_MAX <= x <= -DBL_MIN or DBL_MIN <= x <= DBL_MAX or x==0.0
time_t: TIME_T_MIN <= x <= TIME_T_MAX
* R_EFAULT can be used with rseterr() in your own